let app = getApp();
var applet_park_api_url = app.globalData.applet_park_api_url;
var applet_park_api_url_imgUrl = app.globalData.applet_park_api_url_imgUrl;
const {
  requestDataparams
} = require('../../../utils/request.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: applet_park_api_url_imgUrl,
    type: '',
    dataList:[],
    openId:'',
  },
  click: function (e) {
    var type = e.currentTarget.dataset.type
    this.setData({
      type: parseInt(type),
    })
  },
  showRule: function () {
    this.setData({
      isRuleTrue: true
    })
  },
  hideRule: function () {
    this.setData({
      isRuleTrue: false
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that =this;
    var openId = app.globalData.openId || wx.getStorageSync("OPENID");
    var TOKEN = app.globalData.TOKEN || wx.getStorageSync("TOKEN");
    var nickName = app.globalData.nickName|| wx.getStorageSync('nickName');
    this.setData({
      openId:openId
    })
    
    that.getLists();
  },
  getLists(){
    var that =this;
      requestDataparams('/api/unifiedOrder/queryCanReceiptList',{ openId:that.data.openId}, 'POST','json').then(response=>{
                   
                  if(response.data.code == 0){
                    var datas = response.data.data.records;
                    for(var i=0; i<datas.length; i++){
                      
                      datas[i].totalMoney = parseInt(datas[i].totalMoney)/100;
                      
                      //  datas[i].totalMoney = datas[i].totalMoney.substring(0, datas[i].totalMoney.length-2)+'.00'
                    }
                    that.setData({
                      dataList: datas
                    })
                    
                  }else{
                    wx.showToast({
                      title: '失败',
                      icon:'none'
                    })
                  }
          })
  },
  enterDetails(e){
     
     var id = e.currentTarget.dataset.id;
     var price =  e.currentTarget.dataset.price;
     var orderNum = e.currentTarget.dataset.ordernum;
     var orderType = e.currentTarget.dataset.ordertype;
     wx.navigateTo({
       url: '../invoice_makeout/makeoutinvoice?id='+id+'&price='+price+'&orderType='+orderType,
     })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})